package com.snail.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snail.mapper.BizChatMessageMapper;
import com.snail.model.pojo.BizChatMessage;
import com.snail.service.BizChatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Monica
* @description 针对表【biz_chat_massege】的数据库操作Service实现
* @createDate 2025-07-24 10:30:22
*/
@Service
public class BizChatMessageServiceImpl extends ServiceImpl<BizChatMessageMapper, BizChatMessage>
    implements BizChatMessageService {

    @Autowired
    private BizChatMessageMapper bizChatMessageMapper;
    @Override
    public void saveChatMessage(Integer userId, String chatId, String message,String chatName) {
        LambdaQueryWrapper<BizChatMessage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BizChatMessage::getChatId,chatId);
        BizChatMessage bizChatMassege = bizChatMessageMapper.selectOne(queryWrapper);
        if(bizChatMassege == null){
            bizChatMassege = new BizChatMessage();
            bizChatMassege.setUserId(userId);
            bizChatMassege.setChatId(chatId);
            bizChatMassege.setMessage(message);
            bizChatMassege.setChatName(chatName);
            bizChatMessageMapper.insert(bizChatMassege);
        }
    }
}




